import React, { Component } from 'react';
import axios from 'axios';
import 'utils/cookie'
import action from 'action'
import {connect} from 'react-redux'
import {bindActionCreators} from 'redux'

class Home extends Component{

    componentDidMount(){

        // const uid = window.cookie.get('uid');
        const token = window.cookie.get('token');
        if(token){
            this.props.getUserInfo()
            this.props.getUserMusic()
            axios({
                url:'http://localhost:4000/login/refresh',
                withCredentials: true
            }).then(res=>console.log(res))
            .catch(error=>console.log(error))
        }
        
        // this.props.getUserInfo()

    }
    render(){
        return(
            // 添加过渡动画类名
            <div className="animated fadeIn ">
                {this.props.userReducer.backgroundUrl }
            </div>
        )
    }
}
const mapStateFromProps = state => {
    return state //传递state
  }
  
const mapDispatchToProps = dispatch => {
    return bindActionCreators( action,dispatch )
}
export default connect( mapStateFromProps,mapDispatchToProps )(Home)